package com.example.hotelmanager.ui.activity;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;

import com.example.hotelmanager.R;
import com.example.hotelmanager.widget.MainContentFragment;
import com.example.hotelmanager.widget.RightMenuFragment;
import com.slidingmenu.lib.SlidingMenu;

public class MainActivity extends BaseActivity {
	// private LeftMenuFragment mLeftMenuFragment;

	private MainContentFragment mainFragment;

	private RightMenuFragment mRightMenuFragment;

	protected ListFragment mFrag;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// set the Behind View
		// setBehindContentView(R.layout.menu_frame);
		// if (savedInstanceState == null)
		// {
		// FragmentTransaction t =
		// this.getSupportFragmentManager().beginTransaction();
		// mLeftMenuFragment = new LeftMenuFragment();
		// t.replace(R.id.menu_frame, mLeftMenuFragment);
		// t.commit();
		// }
		// else
		// {
		// mLeftMenuFragment =
		// (LeftMenuFragment)this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
		// }
		getSupportActionBar().hide();
		// customize the SlidingMenu
		SlidingMenu sm = getSlidingMenu();
		sm.setShadowWidthRes(R.dimen.shadow_width);
		sm.setShadowDrawable(R.drawable.shadow);
		sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		sm.setFadeDegree(0.35f);
		sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

		getSupportActionBar().setDisplayHomeAsUpEnabled(true);

		getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
		getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);

		setContentView(R.layout.content_frame);
		getSupportFragmentManager().beginTransaction()
				.replace(R.id.content_frame, new MainContentFragment())
				.commit();

		getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_two);
		getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
		getSupportFragmentManager().beginTransaction()
				.replace(R.id.menu_frame_two, new RightMenuFragment()).commit();

	}

	public void goToLeftLayout(View v) {
		getSlidingMenu().toggle();
	}

	public void goToRightLayout(View v) {
		getSlidingMenu().showSecondaryMenu();
	}

}
